﻿Imports FM.NetBouncer.Rules

''' <summary>
''' Predifined Rule Sets
''' </summary>
''' <remarks></remarks>
Public Class RuleSets

    ''' <summary>
    ''' Integer Validator
    ''' </summary>
    ''' <returns></returns>
    Public Shared Function IntegerSet() As RuleSet(Of String)
        Dim IntegerRuleSet As New RuleSet(Of String)
        IntegerRuleSet.Rules.Add(New IsInteger())
        Return IntegerRuleSet
    End Function

    ''' <summary>
    ''' Hostname validator, according to RFC (Also max : 63 characters)
    ''' </summary>
    ''' <remarks>
    ''' This is not valid domain name RuleSet. This is for hostnames.
    ''' </remarks>
    ''' <returns></returns>
    Public Shared Function HostNameSet() As RuleSet(Of String)

        Dim HostNameRS As New RuleSet(Of String)

        'New Whitelist
        Dim WhiteList As New WhiteListCharacters()
        WhiteList.AddListFromString(Patterns.EnglishAlphaMixedCase)
        WhiteList.AddListFromString(Patterns.Numerical)
        WhiteList.AddListFromString("-.")

        With HostNameRS.Rules
            .Add(New Rules.IsNotNull)
            .Add(New Rules.IsDataInRange(1, 64))
            .Add(WhiteList)
        End With

        Return HostNameRS
    End Function


End Class
